<?php

class frontendConfiguration extends sfApplicationConfiguration
{
	public function configure()
    {
        $this->dispatcher->connect('form.post_configure', array($this, 'listenToPostConfigure'));
    }

    static function listenToPostConfigure(sfEvent $event)
    {

        $form = $event->getSubject();
        $widgetSchema = $form->getWidgetSchema();
        foreach ($form->getValidatorSchema()->getFields() as $fieldName => $validator)
        {
            if (isset($widgetSchema[$fieldName]) && true === $validator->getOption('required'))
            {
                $label = $widgetSchema[$fieldName]->getLabel() ? $widgetSchema[$fieldName]->getLabel() : sfInflector::humanize($fieldName);
                $widgetSchema[$fieldName]->setLabel($label . '&nbsp;<span style="color:#D00000">*</span>');
            }

        }
    }
}
